#include "stdafx.h"
#include "AnimalFactory.h"
#include "Rabbit.h"
#include "RabbitFactory.h"
#include "ReflexDeflex.h"
#include "Animal.h"

AnimalFactory::AnimalFactory()
{
	
}


AnimalFactory::~AnimalFactory()
{
}

Animal* AnimalFactory::CreateAnimal(string name)
{
	if (classMap.end() != classMap.find(name))
	{
		return classMap[name]();
	}
	else
	{
		return nullptr;
	}
}

AnimalFactory* AnimalFactory::getAnimalFactory()
{
	static AnimalFactory* animalFactory;
	if (animalFactory == nullptr)
		animalFactory = new AnimalFactory();
	return animalFactory;
}

void AnimalFactory::resiger(string className, FUNC funcName)
{
	classMap[className] = funcName;
}

